<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="java.lang.*,java.util.*" %>

<!Doctype>
<html>
<head><title>bookList</title></head>

<script type="text/javascript">

</script>
<body>
	<div id="data">
		<table id="booklist" border="1" style="width:50%">
			<tr>
				<th>图书编号</th>
				<th>书名</th>
				<th>作者</th>
				<th>出版社</th>
				<th>价格</th>
				<th>类型</th>
				<th>数量</th>
				<th>藏书地点</th>
			</tr>
			
			<c:forEach items="${bookList }" var="b">
				<tr>
					<td align="center">${b.book_id }</td>
					<td align="center">${b.book_name }</td>
					<td align="center">${b.author }</td>
					<td align="center">${b.publish }</td>
					<td align="center">${b.price }</td>
					<td align="center">${b.type }</td>
					<td align="center">${b.num }</td>
					<td align="center">${b.place }</td>
					<td align="center"><a href="../book/toUpdate.do?name=${b.book_id }">修改</a></td>
					<td align="center"><input type="button" onclick="location.href='../book/delete.do';" value="删除"></td>
				</tr>
			</c:forEach>
		</table>
		
		<a href="/work/index.jsp">返回</a>
	</div>
	
	<!-- 分页区 -->
	<div class="padding">
		<div class="left">共${bookNum }条记录</div>
		<div class="right">
			<c:if test="${currentPage == 1}">
				<span class="disabled">上一页</span>
			</c:if>
			<c:if test="${currentPage != 1}">
				<a href="/work/book/listBook.do?page=${currentPage-1 }">上一页</a>
			</c:if>
			<c:if test="${currentPage == 1}">
         		<span class="current">1</span>
         	</c:if>
         	<c:if test="${currentPage != 1}">
         		<a href="/work/book/listBook.do?page=1">1</a>
         	</c:if>
         	
         	<%
         		int totalPage = (Integer)request.getAttribute("totalPage");
         		
         		for(int i=1;i<totalPage;i++){
         			
     				request.setAttribute("page", i+1);
         	%>
         	<c:if test="${currentPage == page}">
            	<span class="current"><%=i+1%></span>       
         	</c:if>
        	<c:if test="${currentPage != page}">
             	<a href="/work/book/listBook.do?page=<%=i+1%>"><%=i+1%></a>
        	</c:if>
        	<%
         		}
        	%>
        	
        	<c:if test="${currentPage == totalPage}">
            	<span class="disabled">下一页</span>        
      		</c:if>
         	<c:if test="${currentPage != totalPage}">
        		<a href="/work/book/listBook.do?page=${currentPage+1}">后一页</a>
        	</c:if>
			</div>
	</div>
</body>
</html>

